#!/usr/bin/python

import re
import urllib

def getHTML(url) :
	page = urllib.urlopen(url)
	html = page.read()
	return html

def getIMG(html) :
	imgre = re.compile(r'src="(.+?\.jpg)" width')
	imglist = re.findall(imgre, html)
	x = 1
	for imgurl in imglist :
		urllib.urlretrieve(imgurl, '%s.jpg' % x)
		print "download image " + str(x) + " ..."
		x += 1
	return "OK"

html = getHTML("http://www.renren.com")
print getIMG(html)
